﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BabyLearnEnglish_srcum_demo
{
    public partial class frmXemDiem : Form
    {
        public frmXemDiem()
        {
            InitializeComponent();
        }

        private void btnDong_Click(object sender, EventArgs e)
        {
            Close();
        }

        struct HighScore
        {
            public string Name;
            public int Score;
        };

        private void frmXemDiem_Load(object sender, EventArgs e)
        {
            List<HighScore> list = new List<HighScore>();
            string line;

            System.IO.StreamReader file = new System.IO.StreamReader("../../data/highscore.txt");          
            while ((line = file.ReadLine()) != null)
            {
                HighScore h;
                h.Name = line.Split('|')[0];
                h.Score = int.Parse(line.Split('|')[1]);
                list.Add(h);
            }
            file.Close();
            dgvHighScore.Rows.Clear();
            for (int i = 0; i < list.Count - 1; i++)
            {
                dgvHighScore.Rows.Add(i + 1, list[i].Name, list[i].Score);                
            }
        }
    }
}
